<template>
	<view class="home">
		<view class="home-container">
			<view class="home-header">
				<view class="home-title">小鹿前端学院</view>
				<view class="home-school">学生信息入口</view>
				<view class="home-show">
					<view class="home-class">
						<text class="show-text" @tap="showContact">班级权益</text>
						<text class="show-shu"></text>
					</view>
					<image class="show-img" src="../../static/imgs/shape.png" mode=""></image>
				</view>
			</view>
			<scroll-view scroll-y="true" :style="'height: '+clintHeight+'px;'">
				<view class="home-content" :style="'height: '+clintHeight+'px;'">
					<Comminty :homeData="homeData"></Comminty>
				</view>
			</scroll-view>
		</view>
			<MyTabbar :selected="selected"></MyTabbar>
	</view>

</template>

<script>
	import MyTabbar from '../../Common/Tabbar/My-Tabbar.vue'
	import Comminty from '../../Component/Comminty/comminty.vue'
	import {getclassList} from '../../Service/class.js'
	export default {
		data() {
			return {
				title: 'Hello',
				selected:0,
				clintHeight:null,
				homeData:[]
			}
		},
		onLoad() {
			this.__init()
		},
		methods: {
			showContact(){
				uni.navigateTo({
					url:'../show-contact/contact'
				})
			},
			async __init(){
				const data = {
					pageNum:1,
					pageSize:10
				}
				const res = await getclassList(data)
				this.homeData = res
				// console.log('res',res)
			}
		},
		//显示只有滑动区域的那一块的高度
		onReady() {
			uni.getSystemInfo({
				success : (res)=> {
					// 获取头部的高度,获取页面节点
					let info = uni.createSelectorQuery().in(this).select('.home-header')
					//获取元素节点位置信息
					info.boundingClientRect((data)=>{
						//data包含元素高度宽度的信息 68是tabbar的高度
						this.clintHeight = res.windowHeight - data.height - 68
						console.log(data)
					}).exec(function(res){
						//这个方法必须执行，不然获取不到数据的信息
					})
				}
			})
		},
		components:{
			MyTabbar,
			Comminty
		}
	}
</script>

<style>
	scroll-view::-webkit-scrollbar{
		display: none;
		width: 0 !important;
		height: 0 !important;
		background: transplant;
	}
	.home-container{
		width: 100vm;
		height: 100%;
		margin-right: -7px;
		background: url('https://fawn.xuexiluxian.cn/api/profile/wechat/bgimg/bg.png') no-repeat;
		background-size: cover;
		box-sizing: border-box;
		margin-bottom: 20rpx;
	}
	.home-header{
		padding: 131rpx 37rpx 0rpx 37rpx;
	}
	.home-title{
		width: 420rpx;
		height: 59rpx;
		font-size: 60rpx;
		font-weight: 600;
		line-height: 80rpx;
		color: #000cff;	
	}
	.home-school{
		width: 326rpx;
		height: 40rpx;
		font-size: 38rpx;
		color: #344356;
		line-height: 50rpx;
		opacity: .8;
		padding: 30rpx 0rpx;
	}
	.home-show{
		width: 290rpx;
		height: 60rpx;
		display: flex;
		justify-content: space-around;
		align-items: center;
		background-color: #5468ff;
		border-radius: 10rpx;
		padding: 0 20rpx;
		box-sizing: border-box;
	}
	.show-class{
		height: 27rpx;
		line-height: 27rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #ffffff;
	}
	.show-shu{
		width: 1rpx;
		height: 28rpx;
		margin: 0 20rpx;
		border-left: 4rpx solid #FFFFFF;
	}
	.show-img{
		width: 28rpx;
		height: 28rpx;
	}
</style>
